Skip to content

Conversation

Vasfed
Copy link
Contributor

@Vasfed Vasfed commented Dec 27, 2024

What was the end-user or developer problem that led to this PR?

This fixes #8369.

When running with readonly filesystem and no tmp directory on ruby 3.4 bundler raises exception on start

What is your fix for the problem, implemented in this PR?

While trying to check global installed plugins bundler internally tries to create tmp user home, which is not needed in this case. Added flag writable to Bundler.user_bundle_path(default true to keep previous behavior) to be able to determine whether intent is to have a writeable directory or nil will suffice.

Make sure the following tasks are checked

@welcome
Copy link

welcome bot commented Dec 27, 2024

Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality.

We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below.

If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack.

For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide

@deivid-rodriguez
Copy link
Contributor

Hi @Vasfed, thanks for the work on fixing this!

My first idea for the fix was something a bit different. It was doing it in two steps:

  • For next patch level version, fix this by rescuing permission errors when finding the temporary directory in Bundler.user_home, and in that case, fallback to the real user home, even if it's unwritable. If Bundler ever needs to actually write to it, we'll get a permission error, which will be expected in readonly systems. Otherwise, things will just work, not only when checking plugins, but whenever this fallback actually happens.

  • For next version allowing minor breaking changes, completely remove the fallback to a temporary user home. Always return the real home, and print a warning if it's not writable. In many years, I've never seen this fallback actually used, and I believe it causes more harm than good.

What do you think?

@Vasfed
Copy link
Contributor Author

Vasfed commented Dec 30, 2024

Hi @deivid-rodriguez at first only rescuing the exception was my first idea too, but in this case there're several warnings to stdout/stderr (from ruby itself and bundler).
Revisiting this - and indeed, I agree with you, for the patch version changes can be lesser - will change the PR accordingly.

About breaking changes - me too never encountered when tmp home is needed and there's no workaround. As for warning - may be print it only if an exception actually occurs

@Vasfed Vasfed force-pushed the fix_ruby34_readonly_fs branch 2 times, most recently from 5a32ec3 to 1ca9085 Compare December 30, 2024 11:18
@Vasfed
Copy link
Contributor Author

Vasfed commented Dec 30, 2024

Changed to only rescue exception

@deivid-rodriguez
Copy link
Contributor

Sorry for the delay @Vasfed. This looks great!

I rebased and made one change to convert the spec to a workflow that runs Bundler on a read-only system. The rationale being that the kind of test added in rubygems/bundler#6482 did not catch the issue introduced with Ruby 3.4, so I prefer to switch to something more realistic that will prevent the problem from being reintroduced in the future.

@deivid-rodriguez deivid-rodriguez changed the title Do not create tmp home directory only to check if there're plugins Fix Bundler failing to run on read-only filesystems in Ruby 3.4 Jan 10, 2025
@deivid-rodriguez deivid-rodriguez changed the title Fix Bundler failing to run on read-only filesystems in Ruby 3.4 Fix crash on read-only filesystems in Ruby 3.4 Jan 10, 2025
@deivid-rodriguez
Copy link
Contributor

Thanks so much @Vasfed!

@deivid-rodriguez deivid-rodriguez merged commit 71442ad into ruby:master Jan 10, 2025
91 checks passed
deivid-rodriguez added a commit that referenced this pull request Jan 16, 2025
Fix crash on read-only filesystems in Ruby 3.4

(cherry picked from commit 71442ad)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bundler ArgumentError on readonly filesystem on ruby 3.4

2 participants